home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / clonecd / September 93.img / Archives / Applications / Assorted Programs / PCB Cad / ALLOC.C next >
C/C++ Source or Header  |  1990-10-10  |  634b  |  27 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. /*#include <dos.h>*/
  4.  
  5. /*char far *Alloc( long );*/
  6. void Nomem( void );
  7.  
  8. /*char far *Alloc ( x ) (* allocate x bytes of far memory *)
  9.     long x;
  10.     {
  11.     union REGS regs;
  12.  
  13.     regs.h.ah = 0x48; (* allocate memory dos call *)
  14.     x = (x+15)>>4; (* get number of paragraphs to allocate *)
  15.     regs.x.bx = (int)x;
  16.     intdos( ®s, ®s ); (* call dos; request memory *)
  17.     if (regs.x.cflag) (* memory allocation error *)
  18.         Nomem();
  19.     return( (char far *)((long)regs.x.ax<<16) ); (* make a far pointer *)
  20.     }
  21. */
  22.  
  23. void Nomem () { /* a memory allocation request has failed */
  24.     printf( "out of memory\n" );
  25.     exit( -1 );
  26.     }
  27.